<template>
  <div class="layout-page relative">
    <div
      class="tabs-bg w-full h-108px flex items-end justify-center pb-20px mb-32px"
    >
      <div
        v-for="tab in tabs"
        :key="tab.name"
        class="tab-pane relative cursor-pointer font-size-24px lh-36px fw-500"
        :class="{ 'is-active': tab.name === activeTab }"
        @click="tabClick(tab.name)"
      >
        {{ tab.label }}
      </div>
    </div>
    <div class="layout-page-inner w-95%">
      <keep-alive>
        <InnerContent type="supply" v-if="activeTab === 'supply'" />
      </keep-alive>
      <keep-alive>
        <InnerContent type="demand" v-if="activeTab === 'demand'" />
      </keep-alive>
    </div>
  </div>
</template>

<script setup>
import InnerContent from "./components/content.vue";
const tabs = [
  {
    label: "供给信息",
    name: "supply",
  },
  {
    label: "需求信息",
    name: "demand",
  },
];
const route = useRoute();
const activeTab = ref(route.query.type || "supply");
const tabClick = (name) => {
  activeTab.value = name;
};
</script>

<style lang="less">
.layout-page {
  background: @bg-color;
}
.tabs-bg {
  background: url("/supply-bg.png") no-repeat center;
  background-size: cover;
}
.tab-pane {
  position: relative;
  cursor: pointer;
  font-size: 24px;
  line-height: 36px;
  font-weight: 500;
  margin: 0 15px;
}

.tab-pane:last-child {
  margin-left: 102px;
}

.tab-pane.is-active {
  color: @main-color;
  &::after {
    content: "";
    position: absolute;
    width: 32px;
    height: 4px;
    background: @main-color;
    left: calc(50% - 16px);
    bottom: -20px;
  }
}


@media (max-width: 768px) {
  .tab-pane {
    font-size: 18px;
    line-height: 28px;
    margin: 0 10px;
  }

  .tab-pane:last-child {
    margin-left: 0;
  }
  .info-card {
    width: 95%;
    margin: 0 auto;
  }

  .tabs-bg {
    background-size: contain;
    padding: 10px 0;
  }

  .layout-page-inner {
    width: 100%;
    padding: 0 10px;
  }
}
</style>

